﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace DataSetTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        SqlConnection conn;
        DataSet ds;
        SqlDataAdapter sda;
        private void button1_Click(object sender, EventArgs e)
        {
            
            //string constr = "data source=192.168.20.251;initial catalog=lisdb20180423;user id=lisuser;pwd=lisuser";
            conn = new SqlConnection("server=192.168.20.251;database=lisdb20180423;uid=lisuser;pwd=lisuser");
            SqlCommand cmd = new SqlCommand("select * from xt_user", conn);

            SqlDataAdapter sda = new SqlDataAdapter();

            sda.SelectCommand = cmd;

            DataSet ds = new DataSet();

            sda.Fill(ds, "xt_user");

            dataGridView1.DataSource = ds.Tables[0];





        }
    }
}
